package com.coda.controller;

import com.coda.adminVo.user.UserInfoQueryVo;
import com.coda.result.PageResult;
import com.coda.result.Result;
import com.coda.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/admin/user")
@Api(tags = "用户信息管理")
public class UserController {
    @Autowired
    private UserService userService;
    /**
     * 条件分页查询用户列表
     */
    @GetMapping("/page")
    @ApiOperation("条件分页查询用户列表")
    public Result<PageResult> getPageList(@RequestParam Integer current,
                                          @RequestParam Integer size,
                                          UserInfoQueryVo userInfoQueryVo){
        PageResult pageResult = userService.getPageList(current,size,userInfoQueryVo);
        return Result.ok(pageResult);
    }

    /**
     * 根据id修改用户状态
     */
    @PostMapping("/updateStatusById")
    @ApiOperation("根据id修改用户状态")
    public Result updateStatusById(@RequestParam Long id,@RequestParam Integer status){
        userService.updateStatus(id,status);
        return Result.ok();
    }
}
